#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QDir>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
//    setWindowTitle(tr("widget"));
    ui->pushButton->setText(QObject::tr("chinese"));
    ui->pushButton_2->setText(tr("english"));
    ui->textEdit->setText(tr("test text"));

    bool b = m_translator.load(":/translations/qnote_zh_CN.qm");
    qApp->installTranslator(&m_translator);

    ui->retranslateUi(this);

    ui->textEdit->setText(tr("test text"));

}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    //cn
    qApp->removeTranslator(&m_translator);
//    m_translator.load("qnote_zh_CN.qm", ":/translations");
    m_translator.load(":/translations/qnote_zh_CN.qm");
    qApp->installTranslator(&m_translator);
    ui->retranslateUi(this);

    ui->textEdit->setText(tr("test text"));
}

void Widget::on_pushButton_2_clicked()
{
    //en
    qApp->removeTranslator(&m_translator);
    m_translator.load("qnote_EN.qm", ":/translations");
    qApp->installTranslator(&m_translator);
    ui->retranslateUi(this);

    ui->textEdit->setText(tr("test text"));
}
